package com.msdemo.order.controller;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.msdemo.order.service.client.UserServiceClient;

/**
* @comments
* @author zg
* @date 2017年9月28日
*/
@RestController
@RequestMapping("/order/")
public class OrderContnroller {
	private Logger logger = LogManager.getLogger(this.getClass());
	
	@Autowired
	private UserServiceClient userServiceClient;
	
	@RequestMapping("create")
	public String createOrder(@RequestParam(name="userName", required = true) String userName,
							  @RequestParam(name="goodsId", required = true) String goodsId) {
		
		logger.info("订单服务：创建订单 - 用户：{}, 商品ID：{}", userName, goodsId);
		
		logger.info("订单服务：订单创建成功，调用“用户服务”为用户增加积分...");
		userServiceClient.integral(userName, 2);
		return "success";
	}
}
